<template>
  <div class="edu-page-warp">
      <condition-card @reset="reset" @search="onSubmit" label-width="80px" label-position="right">
      <!--<el-form :model="queryForm" ref="queryForm" label-width="80px" size="mini" class="bg-white pd-12px">-->
        <el-row :gutter="24" style="height: 50px;">
          <el-col :span="8">
            <el-form-item label="年级:">
              <el-select v-model="queryForm.grade" style="width: 80%;">
                <el-option v-for="item in options.grade" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="国际学生:">
              <el-select v-model="queryForm.international" style="width: 80%;">
                <el-option v-for="item in options.international" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="学院:">
              <el-select v-model="queryForm.college" @change="changeFaculty" style="width: 80%;">
                <el-option v-for="item in options.college" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24" style="height: 50px;">
          <el-col :span="8">
            <el-form-item label="专业:">
              <el-select v-model="queryForm.profession" style="width: 80%;">
                <el-option v-for="item in options.profession" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="状态:">
              <el-select v-model="queryForm.status" style="width: 80%;">
                <el-option v-for="item in options.status" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </condition-card>
    <el-card>
      <!-- <el-row :gutter="0">
        <el-col>
          <p class="section-title">学生导师管理列表</p>
        </el-col>
      </el-row> -->
      <div class="edu-page-title">学生导师管理列表</div>
      <el-row :gutter="0" class="bg-white pd-20px">
        <el-col>
          <el-row :gutter="0" style="height: 50px;border-bottom: 1px solid #d2d4d6;">
            <el-col :span="3">
              <el-select v-model="queryForm.selectLabelText" size="mini" @change="changeSearchType">
                <el-option v-for="item in options.selectType" :key="item.value" :label="item.label" :value="item.label">
                </el-option>
              </el-select>
            </el-col>
            <el-col :span="5">
              <el-input type="text" v-model="queryForm.condition" :placeholder="queryForm.selectTypeText=='0'?'学号或姓名搜索':'工号或姓名搜索'" size="mini" @keyup.enter.native="filter">
                <i class="el-icon-search" slot="suffix" style="margin-top:7px;cursor: pointer;" @click="filter">
                </i>
              </el-input>
            </el-col>
            <el-col :span="8">
              <div class="empty-box"></div>
            </el-col>
            <el-col :span="8">
              <div class="float-right">
                <el-button @click="publish" v-if="functions['develop']" size="mini">发布</el-button>
                <el-button @click="exportToExcel" size="mini">导出</el-button>
              </div>
            </el-col>
          </el-row>
          <!-- <el-row :gutter="0" class="no-margin">
            <el-col> -->
              <el-table stripe :data="students" size="mini" @selection-change="chooseStudent">
                <el-table-column type="selection" width="50"></el-table-column>
                <el-table-column prop="studentId" label="学号" width="100"></el-table-column>
                <el-table-column prop="name" label="姓名" width="100"></el-table-column>
                <el-table-column label="学院">
                  <template slot-scope="props">
                    <el-popover placement="bottom-start" width="200" trigger="hover" :content="props.row.departmentName">
                      <span slot="reference">{{props.row.departmentName}}</span>
                    </el-popover>
                  </template>
                </el-table-column>
                <el-table-column label="专业">
                  <template slot-scope="props">
                    <el-popover placement="bottom-start" width="200" trigger="hover" :content="props.row.professionName">
                      <span slot="reference">{{props.row.professionName}}</span>
                    </el-popover>
                  </template>
                </el-table-column>
                <el-table-column prop="year" label="年级" width="80"></el-table-column>
                <el-table-column label="导师申请" width="100">
                  <template slot-scope="scope">
                    <el-tag v-if="scope.row.teacherId" type="success" size="mini">已选择</el-tag>
                    <el-tag v-if="!scope.row.teacherId" type="info" size="mini">未选择</el-tag>
                  </template>
                </el-table-column>
                <el-table-column label="导师工号" width="100">
                  <template slot-scope="props">
                    {{props.row.teacherId}}
                  </template>
                </el-table-column>
                <el-table-column label="导师姓名" width="100">
                  <template slot-scope="props">
                    {{props.row.teacherName}}
                  </template>
                </el-table-column>
                <el-table-column label="申请时间" width="100">
                  <template slot-scope="props">
                    {{props.row.applyDate}}
                  </template>
                </el-table-column>
                <el-table-column label="操作" width="80">
                  <template slot-scope="scope">
                    <el-button type="text" v-if="functions['apply_teacher']" @click="openTeacherDialog(scope.row)" size="mini">
                      {{scope.row.teacherId?"更换导师":"申请导师"}}
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
          </el-row>
          <el-row :gutter="0">
            <el-col>
              <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="queryForm.pageNum_" :page-sizes="[20, 50,100,500,1000]" :page-size="queryForm.pageSize_" layout="total, sizes,prev, pager, next,jumper" :total="queryForm.total" style="float: right;margin:10px 60px 0 0;">
              </el-pagination>
            </el-col>
          </el-row>
        <!-- </el-col>
      </el-row> -->
      <!--申请导师对话框-->
      <el-dialog title="申请导师" width="60%" :visible.sync="showTeachersDialog">
        <el-form :model="queryTeacherForm" ref="queryTeacherForm" label-width="80px" size="mini" class="bg-white">
          <el-row :gutter="0">
            <el-col :span="12">
              <el-form-item label="年级:">
                <el-select v-model="queryTeacherForm.year" size="mini">
                  <el-option v-for="item in options.grade" :key="item.value" :label="item.label" :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学院:">
                <el-select v-model="queryTeacherForm.departmentName" size="mini" @change="changeTeacherFaculty">
                  <el-option v-for="item in options.college" :key="item.value" :label="item.label" :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="专业:">
                <el-select v-model="queryTeacherForm.professionName" size="mini">
                  <el-option v-for="item in options.teacherProfession" :key="item.value" :label="item.label" :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item class="float-right">
                <el-button @click="resetTeacher" size="mini">重置</el-button>
                <el-button type="primary" @click="getTeacherList" size="mini">筛选</el-button>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <el-row>
          <el-col :span="8">
            <el-input type="text" v-model="queryTeacherForm.condition" placeholder="工号或姓名" size="mini" @keyup.enter.native="getTeacherList">
              <i class="el-icon-search" slot="suffix" style="margin-top:7px;cursor: pointer;" @click="getTeacherList">
              </i>
            </el-input>
          </el-col>
        </el-row>
        <el-row>
          <el-table :data="teachers" stripe size="mini">
            <el-table-column width="60" label="序号">
              <template slot-scope="scope">
                <el-radio v-model="selectedTeacher" :label="scope.row.teacherId">{{scope.row.id}}</el-radio>
              </template>
            </el-table-column>
            <el-table-column prop="teacherId" label="工号" width="100"></el-table-column>
            <el-table-column prop="name" label="姓名" width="100"></el-table-column>
            <el-table-column label="性别" width="80">
              <template slot-scope="scope">
                {{scope.row.sex}}
              </template>
            </el-table-column>
            <el-table-column label="学院">
              <template slot-scope="scope">
                <el-popover placement="bottom-start" width="300" trigger="hover" :content="scope.row.department">
                  <span slot="reference">{{scope.row.department}}</span>
                </el-popover>
              </template>
            </el-table-column>
            <el-table-column label="计划人数" width="90">
              <template slot-scope="scope">
                {{scope.row.planNum}}
              </template>
            </el-table-column>
            <el-table-column label="实际人数" width="90">
              <template slot-scope="scope">
                {{scope.row.actNum}}
              </template>
            </el-table-column>
            <el-table-column label="介绍">
              <template slot-scope="scope">
                <el-popover placement="bottom-start" width="300" trigger="hover" :content="scope.row.introduce">
                  <span slot="reference">{{scope.row.introduce.substr(0,10)+".."}}</span>
                </el-popover>
              </template>
            </el-table-column>
          </el-table>
        </el-row>
        <el-row :gutter="0">
          <el-col :span=12>
            <span style="line-height:32px">总数：{{queryTeacherForm.total}}</span>
          </el-col>
          <el-col :span=12>
            <el-pagination @current-change="handleCurrentTeachearChange" :current-page="queryTeacherForm.pageNum_" :page-size="queryTeacherForm.pageSize_" layout="prev,pager,next" :total="queryTeacherForm.total" style="float:right;">
            </el-pagination>
          </el-col>
        </el-row>
        <el-row :gutter="0">
          <el-col :span=24>
            <div class="float-right">
              <el-button @click="cancalApple" size="mini">取消</el-button>
              <el-button type="primary" @click="confirmApple" size="mini">确定</el-button>
            </div>
          </el-col>
        </el-row>
      </el-dialog>
      <!--申请导师对话框结束-->
      <!--申请变更-->
      <el-dialog title="更换导师" width="60%" :visible.sync="showChangeDialog">
        <el-row :gutter="0">
          <el-col :span=8>
            <el-input type="text" v-model="queryTeacherForm.showTeacherId" placeholder="搜索指定导师工号" size="mini" @keyup.enter.native="findTeacherInfo(queryTeacherForm.showTeacherId)">
              <i class="el-icon-search" slot="suffix" style="margin-top:7px;cursor: pointer;" @click="findTeacherInfo(queryTeacherForm.showTeacherId)">
              </i>
            </el-input>
          </el-col>
        </el-row>
        <el-row :gutter="0">
          <el-col :span=24>
            <el-row style="margin:10px;min-height:180px">
              <el-col :span=4 style="margin-top:10px">
                <span><img :src="teacherInfo.photo" width="120" height="150" /></span>
              </el-col>
              <el-col :span=20>
                <el-row style="margin:10px 0">
                  <el-col :span=8>
                    <div class="item-group">
                      <label class="secondary-text">工号：</label>
                      <span class="majoy-text">{{teacherInfo.teacherId}}</span>
                    </div>
                  </el-col>
                  <el-col :span=8>
                    <div class="item-group">
                      <label class="secondary-text">姓名：</label>
                      <span class="majoy-text">{{teacherInfo.name}}</span>
                    </div>
                  </el-col>
                  <el-col :span=8>
                    <div class="item-group">
                      <label class="secondary-text">性别：</label>
                      <span class="majoy-text">{{teacherInfo.sex}}</span>
                    </div>
                  </el-col>
                </el-row>
                <el-row style="margin:10px 0">
                  <el-col :span=8>
                    <div class="item-group">
                      <label class="secondary-text">职称：</label>
                      <span class="majoy-text">{{teacherInfo.title}}</span>
                    </div>
                  </el-col>
                  <el-col :span=8>
                    <div class="item-group">
                      <label class="secondary-text">学院：</label>
                      <span class="majoy-text">{{teacherInfo.department}}</span>
                    </div>
                  </el-col>

                  <el-col :span=8>
                    <div class="item-group">
                      <label class="secondary-text">专业：</label>
                      <span class="majoy-text">{{teacherInfo.profession}}</span>
                    </div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span=24>
                    <div class="item-group">
                      <div class="float-left">
                        <label class="secondary-text">简介：</label>
                      </div>
                      <div class="float-right">
                        <label class="majoy-text">{{teacherInfo.introduce}}</label>
                      </div>
                    </div>
                  </el-col>
                </el-row>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span=3>
                <label class="secondary-text">变更原因：</label>
              </el-col>
              <el-col :span=21>
                <el-input type="textarea" :rows="4" placeholder="请输入内容" v-model="teacherInfo.textarea">
                </el-input>
              </el-col>
            </el-row>
            <!-- <el-row style="margin:10px 0">
              <el-col :span=3>
                <label class="secondary-text">附件上传：</label>
              </el-col>
              <el-col :span=21>
                <el-button size="mini">点击上传</el-button>
              </el-col>
            </el-row> -->
          </el-col>
        </el-row>
        <el-row :gutter="0" style="margin-top:20px">
          <el-col :span=24>
            <div class="float-right">
              <el-button @click="cancalChange" size="mini">取消</el-button>
              <el-button @click="confirmChange" type="primary" size="mini">确定</el-button>
            </div>
          </el-col>
        </el-row>
      </el-dialog>
      <!--申请变更结束-->
    </el-card>
  </div>
</template>
<script>
import {
    findAllStudentList,
    findApplyTeacherList,
    addStudentTeacherMap,
    findTeacherById,
    exportStudentList,
    updateStudentTeacherMap,
    updateApplyStatus,
    getImageData
} from "common/src/api/teacherinfo";
import { queryDic } from "common/src/api/dictionary";
export default {
    name: "StudentTeacherMgr",
    data() {
        return {
            defaultPhoto: "/static/images/icon_photo.png",
            showTeachersDialog: false,
            showChangeDialog: false,
            queryForm: {
                grade: "",
                trainingLevel: "",
                international: "",
                college: "",
                profession: "",
                status: "",
                selectLabelText: "按学生搜索",
                selectTypeText: "0",
                pageSize_: 20,
                pageNum_: 1,
                total: 0,
                condition: ""
            },
            queryTeacherForm: {
                year: "",
                departmentName: "",
                professionName: "",
                condition: "",
                pageSize_: 20,
                pageNum_: 1,
                total: 0,
                teacherId: "",
                showTeacherId: "",
                newTeacherId: ""
            },
            options: {
                grade: [],
                international: [],
                college: [],
                profession: [],
                status: [
                    { label: "已选择", value: 1 },
                    { label: "未选择", value: 2 }
                ],
                selectType: [
                    { label: "按学生搜索", value: 0 },
                    { label: "按老师搜索", value: 1 }
                ],
                teacherProfession: []
            },
            students: [],
            teachers: [],
            selectedTeacher: "",
            selectedStudent: "",
            teacherInfo: {
                teacherId: "",
                name: "",
                department: "",
                introduce: "",
                profession: "",
                textarea: "",
                title: "",
                sex: ""
            },
            functions: []
        };
    },
    created:function(){
      this.$store.getters.getFuncUnderPage(this.$route.path).then(funcs=>{
        this.functions=funcs;
      })
    },
    mounted: function() {
        this.init();
        this.getStudentList(); //默认加载学生列表
    },
    methods: {
        init: function() {
            //年
            let year = new Date().getFullYear();
            for (let i = year; i > year - 6; i--) {
                this.options.grade.push({ label: i, value: i });
            }
            //字典数据
            let data = {
                lang: this.$store.getters.language || "cn",
                type: "allChild",
                keys: ["X_YX", "isAborad"]
            };
            queryDic(data)
                .then(res => {
                    if (res.code == 200) {
                        this._fill("international", res.data.isAborad);
                        this._fill("college", res.data.X_YX);
                    }
                })
                .catch(err => {
                    console.log(err);
                });
        },
        _fill(type, data) {
            for (let key in data) {
                this.options[type].push({
                    value: key,
                    label: data[key]
                });
            }
        },
        exportToExcel() {
            let params = {
                condition: this.queryForm.condition,
                grade: this.queryForm.grade,
                trainingLevel: this.queryForm.trainingLevel,
                international: this.queryForm.international,
                college: this.queryForm.college,
                profession: this.queryForm.profession,
                status: this.queryForm.status,
                selectTypeText:this.queryForm.selectTypeText,
                "x-token":
                    this.$store.state.session.sessionid ||
                    localStorage.getItem("sessionid") ||
                    ""
            };
            console.log(params);
            let url = exportStudentList(params);           
            window.open(url);
        },
        reset() {
            this.queryForm.grade = "";
            this.queryForm.international = "";
            this.queryForm.college = "";
            this.queryForm.profession = "";
            this.queryForm.status = "";
        },
        resetTeacher() {
            this.queryTeacherForm.condition = "";
            this.queryTeacherForm.year = "";
            this.queryTeacherForm.departmentName = "";
            this.queryTeacherForm.professionName = "";
            this.options.teacherProfession = [];
        },
        publish() {
            let data = {
                grade: this.queryForm.grade,
                college: this.queryForm.college,
                profession: this.queryForm.profession
            };
            updateApplyStatus(data)
                .then(response => {
                    if (response.code == 200) {
                        this.$message({
                            type: "success",
                            message: "发布成功"
                        });
                    } else {
                        throw response.msg;
                    }
                })
                .catch(err => {
                    this.$message({
                        type: "error",
                        message: "发布失败"
                    });
                });
        },
        onSubmit() {
            this.queryForm.pageNum_ = 1;
            this.getStudentList();
        },
        filter() {
            this.onSubmit();
        },
        //改变学生的学院条件
        changeFaculty(val) {
            this.options["profession"] = [];
            this.queryForm.profession = "";
            let data = {
                lang: this.$store.getters.language || "cn",
                type: "allChild",
                keys: ["G_ZY"],
                filter: {
                    prefix: [val],
                    specilaCode: "XY2ZY"
                }
            };
            queryDic(data)
                .then(res => {
                    if (res.code == 200)
                        this._fill("profession", res.data.G_ZY);
                })
                .catch(error => {
                    console.log(error);
                });
        },
        changeSearchType(val) {
            this.options.selectType.forEach((item, index) => {
                if (item.label == val) {
                    this.queryForm.selectTypeText = item.value;
                }
            });
        },
        //改变导师的学院条件
        changeTeacherFaculty(val, fn) {
            this.options.teacherProfession = [];
            this.queryTeacherForm.profession = "";
            let data = {
                lang: this.$store.getters.language || "cn",
                type: "allChild",
                keys: ["G_ZY"],
                filter: {
                    prefix: [val],
                    specilaCode: "XY2ZY"
                }
            };
            queryDic(data)
                .then(res => {
                    if (res.code == 200) {
                        this._fill("teacherProfession", res.data.G_ZY);
                        if (fn) fn();
                    }
                })
                .catch(error => {
                    console.log(error);
                });
        },
        //获取学生列表
        getStudentList() {
            findAllStudentList(this.queryForm)
                .then(response => {
                    if (response.code == 200) {
                        this.students = response.data.list;
                        this.queryForm.total = response.data.total;
                        this.students.forEach(item => {
                            if (item.choseTime) {
                                let date = new Date(item.choseTime);
                                item.applyDate =
                                    date.getFullYear() +
                                    "-" +
                                    (date.getMonth() + 1 < 10
                                        ? "0" + (date.getMonth() + 1)
                                        : date.getMonth() + 1) +
                                    "-" +
                                    (date.getDate() < 10
                                        ? "0" + date.getDate()
                                        : date.getDate());
                            } else {
                                item.applyDate = "";
                            }
                        });
                    } else {
                        throw response.msg;
                    }
                })
                .catch(error => {
                    this.$message({
                        type: "error",
                        message: "查询失败"
                    });
                });
        },
        //获取导师列表
        getTeacherList(isGotoFirstPage = true) {
            if (isGotoFirstPage) {
                this.queryTeacherForm.pageNum_ = 1;
            }
            this.selectedTeacher = "";
            findApplyTeacherList(this.queryTeacherForm)
                .then(response => {
                    if (response.code == 200) {
                        response.data.list.forEach(
                            (t, index) => (t.id = index + 1)
                        );
                        this.teachers = response.data.list;
                        this.queryTeacherForm.total = response.data.total;
                    } else {
                        this.teachers = [];
                        this.queryTeacherForm.total = 0;
                        throw response.msg;
                    }
                })
                .catch(error => {
                    this.$message({
                        type: "error",
                        message: "查询失败"
                    });
                });
        },
        handleSizeChange(val) {
            this.queryForm.pageSize_ = val;
            this.getStudentList();
        },
        handleCurrentChange(val) {
            this.queryForm.pageNum_ = val;
            this.getStudentList();
        },
        chooseStudent(val) {},
        //显示申请对话框
        openTeacherDialog(row) {
            this.selectedStudent = row.studentId;
            if (row.teacherId) {
                this.showChangeDialog = true;
                this.queryTeacherForm.showTeacherId = row.teacherId;
                this.queryTeacherForm.teacherId = row.teacherId;
                this.teacherInfo.teacherId = "";
                this.teacherInfo.name = "";
                this.teacherInfo.department = "";
                this.teacherInfo.introduce = "";
                this.teacherInfo.textarea = "";
                this.teacherInfo.sex = "";
                this.teacherInfo.title = "";
                this.teacherInfo.photo = this.defaultPhoto;
                this.findTeacherInfo(this.queryTeacherForm.showTeacherId);
            } else {
                this.showTeachersDialog = true;
                this.teachers = [];
                this.selectedTeacher = "";
                this.queryTeacherForm.total = 0;

                this.resetTeacher();

                let option = this.options.college.find(
                    p => p.label == row.departmentName
                );
                if (option) {
                    this.queryTeacherForm.departmentName = option.value;
                    this.changeTeacherFaculty(option.value, () => {
                        if (row.professionName == null) {
                            this.getTeacherList();
                            return;
                        }
                        this.options.teacherProfession.forEach(option => {
                            if (option.label == row.professionName) {
                                this.queryTeacherForm.professionName =
                                    option.value;
                            }
                        });
                        this.getTeacherList();
                    });
                } else {
                    this.getTeacherList();
                }
            }
        },
        //取消申请
        cancalApple() {
            this.showTeachersDialog = false;
        },
        //确认申请
        confirmApple() {
            if (this.selectedTeacher == "") {
                this.$message({
                    type: "type",
                    message: "请选择导师"
                });
            } else {
                let data = {
                    teacherId: this.selectedTeacher,
                    studentId: this.selectedStudent
                };
                addStudentTeacherMap(data)
                    .then(response => {
                        if (response.code == 200) {
                            this.$message({
                                type: "success",
                                message: "申请成功"
                            });
                            this.getStudentList();
                            this.showTeachersDialog = false;
                        } else {
                            throw response.msg;
                        }
                    })
                    .catch(error => {
                        this.$message({
                            type: "error",
                            message: "申请失败"
                        });
                    });
            }
        },
        handleCurrentTeachearChange(val) {
            this.queryTeacherForm.pageNum_ = val;
            this.getTeacherList(false);
        },
        //查询导师详细
        findTeacherInfo(teacherId) {
            if (teacherId) {
                findTeacherById(teacherId)
                    .then(response => {
                        if (response.code == 200 && response.data) {
                            this.teacherInfo.teacherId =
                                response.data.teacherId;
                            this.teacherInfo.name = response.data.name;
                            this.teacherInfo.department =
                                response.data.department;
                            this.teacherInfo.introduce =
                                response.data.introduce;
                            this.teacherInfo.sex = response.data.sex;
                            this.teacherInfo.title = response.data.title;
                            this.queryTeacherForm.newTeacherId = teacherId.replace(
                                /^\s+|\s+$/gm,
                                ""
                            );
                            if (response.data.photo) {
                                getImageData(response.data.photo)
                                    .then(response => {
                                        if (
                                            response.code == 200 &&
                                            response.data
                                        ) {
                                            let obj = {};
                                            Object.assign(
                                                obj,
                                                this.teacherInfo
                                            );
                                            obj.photo = response.data.base;
                                            this.teacherInfo = obj;
                                        }
                                    })
                                    .catch(err => {});
                            } else {
                                this.teacherInfo.photo = this.defaultPhoto;
                            }
                        } else {
                            this.teacherInfo.photo = this.defaultPhoto;
                            throw "查询失败";
                        }
                    })
                    .catch(error => {
                        this.$message({
                            type: "error",
                            message: "查询失败"
                        });
                    });
            } else {
                this.$message({
                    type: "error",
                    message: "查询失败"
                });
            }
        },
        //取消变更
        cancalChange() {
            this.showChangeDialog = false;
        },
        //变更导师
        confirmChange() {
            if (
                this.queryTeacherForm.newTeacherId != "" &&
                this.queryTeacherForm.newTeacherId !=
                    this.queryTeacherForm.teacherId
            ) {
                let data = {
                    teacherId: this.queryTeacherForm.newTeacherId,
                    studentId: this.selectedStudent,
                    oldTeacherId: this.queryTeacherForm.teacherId
                };
                updateStudentTeacherMap(data)
                    .then(response => {
                        if (response.code == 200) {
                            this.$message({
                                type: "success",
                                message: "变更成功"
                            });
                            this.showChangeDialog = false;
                            this.getStudentList();
                        } else {
                            throw response.msg;
                        }
                    })
                    .catch(error => {
                        this.$message({
                            type: "error",
                            message: "变更失败"
                        });
                    });
            } else {
                this.$message({
                    type: "error",
                    message: "变更失败"
                });
            }
        }
    }
};
</script>
<style lang="scss" scoped>
</style>
